﻿#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QTimer>

#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>

namespace Ui {
class Widget;
}

using namespace cv;

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_pushButton_4_clicked();

private:
    Ui::Widget *ui;

private:
    VideoCapture *videocapture;
    Mat matFrame;
    QTimer *timer;
    bool ok;

    QImage refer_image;
    unsigned char greyrefer[640][360];

    bool setrefer;  //是否设置了参照
    bool monitor;   //是否监测
    bool move;      //是否监测到运动
    int  sensitivity;

private:
    void getrefer();
    void playwav();

private slots:
    void readFarme();
    void on_pushButton_clicked();
    void on_pushButton_2_clicked();

    void on_horizontalSlider_valueChanged(int value);

    void on_pushButton_3_clicked();

public:
    QImage Widget::cvMat2QImage(const Mat&);
    Mat Widget::QImage2cvMat(QImage);
};

#endif // WIDGET_H
